home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE06 / TIPTRIX / LISTING3.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-01-13  |  903 b   |  41 lines

  1. type
  2.   TPStringBin=class(TComponent)
  3.   private
  4.     fString: PString;
  5.   protected
  6.     procedure SetString(const Value: String);
  7.     function GetString:String;
  8.   public
  9.     constructor Create(aOwner: TComponent); override;
  10.     destructor Destroy; overide
  11.   published
  12.     aString: String read GetString write SetString;
  13.     end;
  14.  
  15.     
  16. implementation
  17.  
  18.   {no code required for TStringBin}
  19.   
  20. constructor TPStringBin.Create(aOwner:TComponent); 
  21. begin
  22.   inherited Create; {gosub}
  23.   fString:=NullStr; {prepare the PString}
  24. end;  
  25.  
  26. destructor TPStringBin.Destroy; 
  27. begin
  28.   DisposeStr(fString); {free the PString}
  29.   inherited Destroy;   {gosub}
  30. end;  
  31.  
  32. procedure SetString(const Value: String);
  33. begin
  34.   AssignStr(fString,Value); {free old and store new}
  35. end;
  36.  
  37. function GetString:String;
  38. begin
  39.   Result:=fString^;      {fString is a pointer. '^' points to the string}
  40. end;
  41.